Replace the double-traversal pattern in pop_first/pop_last with
single-pass remove_leftmost/remove_rightmost methods. Previously,
pop_last would walk the rightmost spine to find the max key (loading
~4 nodes), then walk the same spine again via remove_helper to delete
it (loading ~4 more nodes). The single-pass approach descends once,
handling rebalancing (rotation/merge) during descent.
Also fix the EXC-1034 TODO in remove_helper cases 2a/2b: replace
get_max + remove_helper with remove_rightmost, and get_min +
remove_helper with remove_leftmost.
Expected improvement: ~50% fewer load_node calls for pop operations,
plus eliminates redundant binary searches on the descent path.
Summary
pop_last/pop_firstwith single-passremove_rightmost/remove_leftmostpop_lastcalledget_max(walks rightmost spine, ~4 node loads) thenremove_helper(walks from root again, ~4 more node loads). Now: single descent, handling rotation/merge during the walkremove_helpercases 2a/2b: replaceget_max + remove_helper(predecessor)withremove_rightmost(left_child), andget_min + remove_helper(successor)withremove_leftmost(right_child)Expected improvement: ~50% fewer
load_nodecalls for pop operations on a depth-4 tree (4 loads vs 8), plus eliminates 4 binary searches per operation.